package com.jdd.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 1.0
 * @Description:
 * @author： jdd尚岳
 * @Date: 2021-05-29 16:01
 */
@Configuration
public class RabbitConfig {
    /**
     * 月租车同步交换机
     */
    @Value("${park.cloud.new.monthly.message.notify.exchange}")
    private String parkCloudMonthlyExchange;

    /**
     *      月租车同步routeKy
     */
    @Value("${park.cloud.new.monthly.route.key}")
    private String parkCloudMonthlyKye;
    /**
     *  月租车队列
     */
    @Value("${park.monthly.queue}")
    private String  parkCloudMonthlyQueue;



    @Value("${park.cloud.message.notify.exchange}")
    private String  parkCloudOredlExchange;

    @Value("${park.station.queue}")
    private String  parkCloudOrderQueue;

    @Value("${park.cloud.route.key}")
    private String  parkCloudRouteKye;

    @Value("${park.stuck.car.queue}")
    private String parkStuckCarQueue;
    @Value("${park.cloud.stuck.car.message.notify.exchange}")
    private String parkCloudStuckCarMessageNotifyExchange;
    @Value("${park.cloud.stuck.car.route.key}")
    private String parkCloudStuckCarRouteKey;



    @Bean
    public TopicExchange reportExchange() {
        return new TopicExchange(parkCloudOredlExchange);
    }

    /**
     * 新版月租车交换机
     * @return
     */
    @Bean
    public TopicExchange reportMonthlyExchange() {
        return new TopicExchange(parkCloudMonthlyExchange);
    }

    /**
     * 滞留车交换机
     * */
    @Bean
    public TopicExchange reportStuckCarExchange(){return new TopicExchange(parkCloudStuckCarMessageNotifyExchange);}
    /**
     * 月租车队列
     * @return
     */
    @Bean
    public Queue parkCloudMonthlyQueue() {
        return new Queue(parkCloudMonthlyQueue);
    }

    @Bean
    public Queue parkCloudOrdelQueue() {
        return new Queue(parkCloudOrderQueue);
    }
    /**
     * 滞留车消息队列
     * */
    @Bean
    public Queue parkStuckCarQueue(){return new Queue(parkStuckCarQueue);}

    @Bean
    public Binding parkOrdelBinding(TopicExchange reportExchange, Queue parkCloudOrdelQueue) {
        Binding binding = BindingBuilder.bind(parkCloudOrdelQueue).to(reportExchange).with(parkCloudRouteKye);
        return binding;
    }

    /**
     * 同步月租车绑定
     *
     * @param reportMonthlyExchange
     * @param parkCloudMonthlyQueue
     * @return
     */
    @Bean
    public Binding parkMonthlyBinding(TopicExchange reportMonthlyExchange, Queue parkCloudMonthlyQueue) {
        Binding binding = BindingBuilder.bind(parkCloudMonthlyQueue).to(reportMonthlyExchange).with(parkCloudMonthlyKye);
        return binding;
    }
    // 滞留车手动出场消息队列绑定
    @Bean
    public Binding parkStuckCarBinding(TopicExchange reportStuckCarExchange,Queue parkStuckCarQueue){
        return BindingBuilder.bind(parkStuckCarQueue).to(reportStuckCarExchange).with(parkCloudStuckCarRouteKey);
    }



}
